import java.util.Scanner;

// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class code4 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] ss = in.next().toCharArray();
        int n = in.nextInt();

        int left = 0;
        int right = 0;

        int retL = 0;
        int retR = 0;
        int count = 0;//G和C的数量
        int Mcount = 0;//最多数量

        while(right < ss.length) {
            //进
            if(ss[right] == 'G' || ss[right] == 'C') {
                count++;
            }
            //判断
            while(right-left+1 > n) {
                //出
                if(ss[left] == 'G' || ss[left] == 'C') {
                    count--;
                }
                left++;
            }
            //更新结果
            if(count > Mcount && right-left+1 == n) {
                retL = left;
                retR = right;
                Mcount = count;
            }
            right++;
        }

        for(int i=retL;i<=retR;i++) {
            System.out.print(ss[i]);
        }
    }
}